Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dev): setup devcontainer for developers #4263

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Oct 27, 2024

See .devcontainer/READMD.md for details.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a development container setup with a new Dockerfile.
    • Added scripts for building C++ and Python components, downloading the LibTorch library, and setting up the environment for LAMMPS simulations.
    • New README documentation for the development environment setup.
    • New configuration file for the development container to streamline setup processes.
  • Bug Fixes

    • Expanded .gitignore to prevent unnecessary files from being tracked.
  • Chores

    • Enhanced dependency management in pyproject.toml for improved organization and clarity.

Signed-off-by: GitHub <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Copy link
Contributor

coderabbitai bot commented Oct 27, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces a comprehensive setup for a development container tailored for the DeePMD-kit project. It includes a Dockerfile for C++ development on Ubuntu 24.04, a README detailing the environment setup, and several shell scripts for building C++ and Python components, downloading libraries, and configuring debugging. Additionally, it updates the .gitignore file and modifies the pyproject.toml for enhanced dependency management.

Changes

File Path Change Summary
.devcontainer/Dockerfile New Dockerfile created for C++ development, specifying a base image and copying files from a GitHub registry.
.devcontainer/README.md New README file added detailing the setup process for the development environment.
.devcontainer/build_cxx.sh New script for automating the C++ build process with TensorFlow and PyTorch integration.
.devcontainer/build_py.sh New script for automating the Python build process and setting up pre-commit hooks.
.devcontainer/devcontainer.json New configuration file for the development container specifying build and environment settings.
.devcontainer/download_libtorch.sh New script for downloading and extracting the LibTorch library.
.devcontainer/gdb_lmp New script for setting up the environment for LAMMPS simulations under gdb.
.devcontainer/lmp New script for executing LAMMPS with the DeepMD plugin.
.gitignore Updated to ignore additional files and directories relevant to the development environment.
pyproject.toml Modifications for improved dependency management, including new sections and a new dependency group.

Possibly related PRs

Suggested labels

Python, Docs

Suggested reviewers

  • wanghan-iapcm

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 19

🧹 Outside diff range and nitpick comments (5)
.devcontainer/download_libtorch.sh (1)

1-8: Add script documentation.

The script would benefit from a header comment explaining its purpose and usage.

Add this at the beginning of the file:

 #!/bin/bash
+# Download and extract LibTorch for C++ development
+#
+# This script downloads the CPU version of LibTorch with C++11 ABI and shared dependencies.
+# Environment variables:
+#   LIBTORCH_VERSION: Override the default LibTorch version (default: 2.5.0)
+
 set -ev
🧰 Tools
🪛 Shellcheck

[warning] 4-4: Quote this to prevent word splitting.

(SC2046)

.devcontainer/lmp (1)

1-9: Add script documentation and usage information.

The script would benefit from a header comment block explaining its purpose and requirements.

Add this documentation at the start of the script:

 #!/bin/bash
+# Script: lmp
+# Purpose: Wrapper script to run LAMMPS with DeepMD-kit integration
+#
+# Requirements:
+# - Python with TensorFlow installed
+# - libtorch directory in ../libtorch
+# - DeepMD-kit installed in ../dp
+# - LAMMPS installed in ../.venv
+#
+# Usage: ./lmp [LAMMPS arguments]
.devcontainer/gdb_lmp (1)

1-1: Add script documentation and debug logging.

Consider adding documentation and debug logging to make the script more maintainable and easier to troubleshoot.

 #!/bin/bash
+
+# gdb_lmp: Debug LAMMPS with DeePMD-kit integration
+#
+# Usage: ./gdb_lmp [gdb_args...]
+#
+# This script sets up the necessary environment variables and paths
+# to debug LAMMPS with DeePMD-kit integration using GDB.
+
+# Enable debug logging if DEBUG is set
+if [ "${DEBUG:-}" = "1" ]; then
+    set -x
+fi
.devcontainer/devcontainer.json (1)

3-5: Consider adding version tags for build reproducibility.

The Dockerfile reference is correct, but consider adding a version tag to ensure consistent builds across different environments and time periods.

 "build": {
-  "dockerfile": "Dockerfile"
+  "dockerfile": "Dockerfile",
+  "tag": "1.0.0"
 }
.devcontainer/build_cxx.sh (1)

1-20: Consider enhancing developer experience with additional features.

As this script is part of the devcontainer setup, consider adding these developer-friendly features:

  1. Add a --clean flag to force clean builds
  2. Add a --verbose flag to control CMake output verbosity
  3. Consider caching build artifacts in a volume for faster rebuilds
  4. Add support for different build types (Release, RelWithDebInfo)

Would you like me to provide an enhanced version of the script with these features?

🧰 Tools
🪛 Shellcheck

[warning] 5-5: Quote this to prevent word splitting.

(SC2046)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 13e247e and 56ef285.

📒 Files selected for processing (10)
  • .devcontainer/Dockerfile (1 hunks)
  • .devcontainer/READMD.md (1 hunks)
  • .devcontainer/build_cxx.sh (1 hunks)
  • .devcontainer/build_py.sh (1 hunks)
  • .devcontainer/devcontainer.json (1 hunks)
  • .devcontainer/download_libtorch.sh (1 hunks)
  • .devcontainer/gdb_lmp (1 hunks)
  • .devcontainer/lmp (1 hunks)
  • .gitignore (1 hunks)
  • pyproject.toml (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .devcontainer/Dockerfile
🧰 Additional context used
🪛 LanguageTool
.devcontainer/READMD.md

[grammar] ~4-~4: The word “setup” is a noun. The verb is spelled with a space.
Context: ...ironment to develop DeePMD-kit. One can setup locally or use [GitHub Codespaces](http...

(NOUN_VERB_CONFUSION)


[typographical] ~30-~30: Consider adding a comma after ‘Usually’ for more clarity.
Context: ... - .devcontainer/gdb_lmp ## Rebuild Usually the Python package does not need to rei...

(RB_LY_COMMA)

🪛 Shellcheck
.devcontainer/build_cxx.sh

[warning] 5-5: Quote this to prevent word splitting.

(SC2046)

.devcontainer/build_py.sh

[warning] 4-4: Quote this to prevent word splitting.

(SC2046)

.devcontainer/download_libtorch.sh

[warning] 4-4: Quote this to prevent word splitting.

(SC2046)

🔇 Additional comments (8)
.devcontainer/build_py.sh (1)

1-8: Consider adding logging and status reporting for CI/CD integration.

As this script is part of the devcontainer setup, it would be beneficial to:

  1. Add structured logging to help with CI/CD pipeline debugging
  2. Generate a status file or environment variables indicating successful completion
  3. Consider adding a cleanup function for failed installations

Let's verify if this script is referenced in CI workflows:

🧰 Tools
🪛 Shellcheck

[warning] 4-4: Quote this to prevent word splitting.

(SC2046)

.devcontainer/lmp (1)

1-9: Verify devcontainer integration and documentation.

Please ensure this script is properly documented in .devcontainer/README.md and that the paths align with the devcontainer setup.

✅ Verification successful

Documentation exists but filename has a typo

The script is properly documented in .devcontainer/READMD.md (note the typo in filename), and the paths align with the devcontainer setup. Specifically:

  • The .venv directory is configured in remoteEnv.PATH
  • libtorch is downloaded and set up by download_libtorch.sh
  • The dp/lib path is created during C++ build process in build_cxx.sh
  • The script usage is explicitly documented in the README: "When calling and debuging LAMMPS with DeePMD-kit, use the following scripts instead of the regular lmp: .devcontainer/lmp"

Two minor issues to address:

  • Rename READMD.md to README.md to follow standard conventions
  • Consider adding error handling for the case when required directories don't exist
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify documentation and path references
echo "Checking documentation references..."
rg -l "lmp" .devcontainer/README.md || echo "Script not documented in README.md"

echo "Checking devcontainer setup..."
# Verify if the required paths are configured in devcontainer setup
rg -l "libtorch|\.venv|dp/lib" .devcontainer/devcontainer.json || echo "Paths may not be configured in devcontainer"

Length of output: 429


Script:

#!/bin/bash
# Let's check the content of devcontainer.json to understand the configuration
echo "Content of devcontainer.json:"
cat .devcontainer/devcontainer.json

# Check if there are any other documentation files in .devcontainer
echo -e "\nListing files in .devcontainer:"
ls -la .devcontainer/

# Check if the required directories exist
echo -e "\nChecking referenced directories:"
ls -la libtorch dp/lib .venv 2>/dev/null || echo "Some directories not found"

Length of output: 1537


Script:

#!/bin/bash
# Let's check the content of READMD.md (note the typo) to see if it contains documentation
echo "Content of .devcontainer/READMD.md:"
cat .devcontainer/READMD.md

# Let's also check the build scripts to understand the directory structure
echo -e "\nContent of build scripts:"
echo "=== build_cxx.sh ==="
cat .devcontainer/build_cxx.sh
echo -e "\n=== build_py.sh ==="
cat .devcontainer/build_py.sh
echo -e "\n=== download_libtorch.sh ==="
cat .devcontainer/download_libtorch.sh

Length of output: 2706

.gitignore (2)

48-50: LGTM! Standard ignore patterns added.

The additions of libtorch/, uv.lock, buildcxx/, and *.bib.original are appropriate for ignoring build artifacts, downloaded dependencies, and temporary files.

Also applies to: 52-52


51-51: Verify the need for node_modules/ ignore pattern.

Could you clarify if there are Node.js dependencies in the project? This might be for documentation or development tools, but it would be helpful to understand the specific use case.

✅ Verification successful

Let me check the contents of the package.json file to better understand the Node.js dependencies.


The node_modules/ ignore pattern is necessary and correctly placed

The project contains Node.js components in the source/nodejs directory with:

  • A valid package.json with node-gyp dependency for native module compilation
  • JavaScript files including index.js and test files
  • Native module build support indicated by gypfile: true

The node_modules/ directory will be created when installing dependencies, so it should be ignored by git.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for Node.js related files to understand the context
# Test: Look for package.json or other Node.js related files
echo "Searching for Node.js related files..."
fd -t f "package.json|package-lock.json|npm"

# Test: Check if any documentation tools use Node.js
echo -e "\nSearching for documentation configuration files..."
fd -t f "docusaurus|vuepress|docsify|mkdocs"

Length of output: 324


Script:

#!/bin/bash
# Check contents of package.json
cat source/nodejs/package.json

# Look for any JavaScript/TypeScript files
echo -e "\nSearching for JS/TS files..."
fd -e js -e ts -e jsx -e tsx

Length of output: 996

.devcontainer/devcontainer.json (1)

9-9: Verify the existence and permissions of referenced scripts.

The configuration references several shell scripts. Let's verify they exist and have proper permissions.

✅ Verification successful

All referenced scripts exist and have proper executable permissions

The verification confirms that all three scripts referenced in the postCreateCommand exist in the .devcontainer directory and have the required executable permissions:

  • .devcontainer/build_py.sh
  • .devcontainer/download_libtorch.sh
  • .devcontainer/build_cxx.sh
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and permissions of required scripts
# Expected: All scripts should exist and be executable

echo "Checking required scripts..."
for script in build_py.sh download_libtorch.sh build_cxx.sh; do
  script_path=".devcontainer/${script}"
  if [ -f "$script_path" ]; then
    echo "✓ Found: ${script}"
    if [ -x "$script_path" ]; then
      echo "✓ Executable: ${script}"
    else
      echo "✗ Not executable: ${script}"
    fi
  else
    echo "✗ Missing: ${script}"
  fi
done

Length of output: 1012

pyproject.toml (3)

154-159: LGTM! Development dependencies are well-defined.

The development dependency group includes essential tools for building and maintaining the project:

  • pre-commit for code quality checks
  • cmake for building C++ components
  • mpich for MPI support

444-450: LGTM! UV source configuration is properly set up.

The configuration correctly sets up a dedicated source for mpich packages using mpi4py's PyPI mirror. The explicit = true flag ensures deterministic package resolution.


139-146: Track UV workaround for future cleanup.

The duplicate entries for jax and flax dependencies are added as a workaround for uv issue #8601. Consider adding a follow-up task to remove these duplicates once the issue is resolved.

✅ Verification successful

Workaround for UV issue #8601 is still necessary

The UV issue #8601 is still open and actively tracked. The duplicate entries for jax, flax, and orbax-checkpoint dependencies are currently required as a workaround. Keep these duplicates until the issue is resolved.

  • The issue specifically affects dependencies using python_version>= constraints
  • Current workaround ensures proper dependency resolution
  • Affects lines 139-146 in pyproject.toml
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the UV issue is still open
gh issue view 8601 --repo astral-sh/uv || echo "Issue not found or closed"

Length of output: 1819

.devcontainer/build_py.sh Show resolved Hide resolved
.devcontainer/build_py.sh Show resolved Hide resolved
.devcontainer/build_py.sh Show resolved Hide resolved
.devcontainer/download_libtorch.sh Show resolved Hide resolved
.devcontainer/download_libtorch.sh Show resolved Hide resolved
.devcontainer/devcontainer.json Show resolved Hide resolved
.devcontainer/build_cxx.sh Show resolved Hide resolved
.devcontainer/build_cxx.sh Show resolved Hide resolved
.devcontainer/build_cxx.sh Show resolved Hide resolved
.devcontainer/build_cxx.sh Outdated Show resolved Hide resolved
Signed-off-by: Jinzhe Zeng <[email protected]>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 56ef285 and 0b87f7a.

📒 Files selected for processing (1)
  • .devcontainer/build_cxx.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck
.devcontainer/build_cxx.sh

[warning] 5-5: Quote this to prevent word splitting.

(SC2046)

.devcontainer/build_cxx.sh Show resolved Hide resolved
.devcontainer/build_cxx.sh Show resolved Hide resolved
Copy link

codecov bot commented Oct 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.35%. Comparing base (13e247e) to head (0b87f7a).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #4263      +/-   ##
==========================================
+ Coverage   84.34%   84.35%   +0.01%     
==========================================
  Files         549      549              
  Lines       51463    51463              
  Branches     3051     3051              
==========================================
+ Hits        43404    43410       +6     
+ Misses       7097     7095       -2     
+ Partials      962      958       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant